# -*- coding: UTF-8 -*-
"""
Create by Louis on 2019/7/25-23:02
"""
# __author__ = "Louis"


import xlrd
# # 打开文件
# data = xlrd.open_workbook('./excelfile/excelzhong.xlsx')
# # 查看工作表
# data.sheet_names()
# print ("sheets:"+str(data.sheet_names()))
#
#
# #通过excel下面的标签名获得工作表1
# print ("取第2个标签为\n"+str(data.sheet_by_name("JackFile")))
# table_Jack = data.sheet_by_name("JackFile")
# #通过excel下面的标签索引获得工作表1，因为这个sheet_names返回的是一个list
# print ("取第1个标签为\n"+str(data.sheet_by_index(0)))
# table_Louis = data.sheet_by_index(0)
#
# #获取总行数nrows
# print ("总行数:"+ str(table_Jack.nrows))
# #获取总列数ncols
# print("总列数："+str(table_Jack.ncols))
# #获取整行的值,参数（start,end）default end =None
# print("总行的值："+str(table_Jack.row_values(0)))
# #获取整列的值
# print("总列的值："+str(table_Jack.col_values(0)))
#
# #获取某个单元格的值，如获取D4单元格的值,行从0开始，列从0开始
# excel_D4 = table_Jack.cell(3,3).value
# print("第三行第三列的值："+excel_D4)
def read_xlrd(**kwargs):
    for key in kwargs:
        data = xlrd.open_workbook(kwargs[key])
        table = data.sheet_by_index(0)
        for rowNum in range(table.nrows):
            rowVale = table.row_values(rowNum)
            for colNum in range(table.ncols):
                if rowNum>0 and colNum==0:
                    print(int(rowVale[0]))
                else:
                    print(rowVale[colNum])
            print("--------------------------")

if __name__=="__main__":
    excelFile1 = './excelfile/excelzhong.xlsx'
    excelFile2 = './excelfile/excelzhong2.xlsx'
    read_xlrd(excelFile1=excelFile1,excelFile2=excelFile2)
    # read_xlrd(excelFile=excelFile1) #也可以这样写